package com.nantai.jiafang.nantaijiafang.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nantai.jiafang.nantaijiafang.R;
import com.nantai.jiafang.nantaijiafang.bean.FabricBatchInfo;

import java.util.List;

/**
 * Created by wuning on 2016/8/9.
 */
public class FebricBatchListAdapter extends BaseAdapter {

    private List<FabricBatchInfo> list;
    private Context mContext;

    public FebricBatchListAdapter(Context context, List<FabricBatchInfo> data) {
        mContext = context;
        list = data;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.fabricbatchdetail, null);
            viewHolder = new ViewHolder();
            viewHolder.tv2_1 = (TextView) convertView.findViewById(R.id.tv2_1);
            viewHolder.tv2_2 = (TextView) convertView.findViewById(R.id.tv2_2);
            viewHolder.tv2_3 = (TextView) convertView.findViewById(R.id.tv2_3);
            viewHolder.tv2_4 = (TextView) convertView.findViewById(R.id.tv2_4);
            viewHolder.tv2_5 = (TextView) convertView.findViewById(R.id.tv2_5);
            viewHolder.tv2_6 = (TextView) convertView.findViewById(R.id.tv2_6);
            viewHolder.tv2_7 = (TextView) convertView.findViewById(R.id.tv2_7);
            viewHolder.tv2_8 = (TextView) convertView.findViewById(R.id.tv2_8);
            viewHolder.tv2_9 = (TextView) convertView.findViewById(R.id.tv2_9);
            viewHolder.tv2_10 = (TextView) convertView.findViewById(R.id.tv2_10);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.tv2_1.setText(list.get(position).getComponentInvName());
        viewHolder.tv2_2.setText(list.get(position).getComponentInvCode());
        viewHolder.tv2_3.setText(list.get(position).getcVenCode());
        viewHolder.tv2_4.setText(list.get(position).getcBatch());
        viewHolder.tv2_5.setText(list.get(position).getLevels());
        viewHolder.tv2_6.setText(list.get(position).getCutCost());
        viewHolder.tv2_7.setText(list.get(position).getPickLength());
        viewHolder.tv2_8.setText(list.get(position).getUseRatePercentText());
        viewHolder.tv2_9.setText(list.get(position).getTimestamp());
        viewHolder.tv2_10.setText(list.get(position).getCutSuitQty());
        return convertView;
    }

    class ViewHolder {
        TextView tv2_1, tv2_2, tv2_3, tv2_4, tv2_5, tv2_6, tv2_7, tv2_8,tv2_9,tv2_10;
    }
}
